#! /bin/bash

#lujing
path=/all_test/install_scripts/

#判断目录是否存在 不存在则创建
[ ! -d "$path" ] && mkdir -p $path
# 给用户输入提示信息
cat <<END
	1.[install lamp]
	2.[install lnmp]
	3.[exit]
	please input the number want:
END
# 读取用户输入的值
read num
# 判断用户是否输入的数字
#test -n "$(${num}|sed 's/[0-9]//g')" && echo 'must to be number'
expr $num + 1 &> /dev/null
## 判断上句结果
[ $? -ne 0 ] && {
	echo 'must to be number!'
}

# 对输入是1、2、3的情况进行处理
[ $num = 1 ] && {
	echo "start installing...lamp.."
	sleep 3
	test -x "$path/lamp.sh" || {
		echo "the file err..."
		exit 1
	}
	$path/lamp.sh
	exit $?
}

[ $num = 2 ] && {
	echo "start installing...lnmp..."
	sleep 2
	[ -x "$path/lnmp.sh" ] || {
		echo "the flie2 err..."
		exit 2
	}
	$path/lnmp.sh
	exit $?
}

[[ $num -eq 3 ]] && {
	echo "bye"
	exit 3
}

# 限制用户只能输入123
[[ ! "$num" =~ [1-3] ]] && {
	echo "please input 1|2|3"
	exit 4
}




